
//a Intersil test program
//this demonstrates some of Intersil project capabilities.

#include "Shered\GlobalFunctions.h"
#include "Intersil.h"
#include <iostream>
#include <memory>
using namespace std;

string MESSAGE_TYPE_TO_STRING(int msgtype)
{
	switch(msgtype)
	{
	case LOGIN:	return "LOGIN";
	case LOGOUT:return "LOGOUT";
	case ADD_PERSON:return "ADD_PERSON";
	case ADD_COURSE:return "ADD_COURSE";
	case DELETE_PERSON:	return "DELETE_PERSON";
	case DELETE_COURSE:	return "DELETE_COURSE";
	case EDIT_PERSON:	return "EDIT_PERSON";
	case REGISTER_STUDENT_COURSE:return "REGISTER_STUDENT_COURSE";
	case ASSIGN_COURSE_LECTURER:return "ASSIGN_COURSE_LECTURER";
	case GET_ALL_COURSE:return "GET_ALL_COURSE";
	case GET_COURSE_DATA:return "GET_COURSE_DATA";
	case GET_PERSON_DATA:return "GET_PERSON_DATA";
	case GET_COURSES_FOR_SEMESTER:return "GET_COURSES_FOR_SEMESTER";
	case ADD_COURSE_PREREQUISITE:return "ADD_COURSE_PREREQUISITE";
	case SET_STUDENT_COURSE_COMPLETED:return "SET_STUDENT_COURSE_COMPLETED";
	default:
		return  "UNKNOWN MESSAGE TYPE";
		break;
	}
}


int runRequest(Intersil &intersil,Request &request);
void addDemoData(Intersil &intersil,string myid);
bool Login(Intersil &intersil)
{
	char s[512];
	cout<<"Enter User ID: ";cin.getline(s,512);
	RequestData request(LOGIN);
 	request.addParameter("ID",s);
 	runRequest(intersil,request);
	if(intersil.isLoggedIn())return true;
	return false;
}
void AssignLecturerToAcourse(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Lecturer ID: ";cin.getline(s,512);
	RequestData request(ASSIGN_COURSE_LECTURER);
	request.addParameter("LectID",s);
	cout<<"Enter Course ID: ";cin.getline(s,512);
	request.addParameter("CourseID",s);
	cout<<"Enter Start Hour: ";cin.getline(s,512);
	request.addParameter("Start_Hour",s);
	cout<<"Enter End Hour: ";cin.getline(s,512);
	request.addParameter("End_Hour",s);
	cout<<"Enter Semester: ";cin.getline(s,512);
	request.addParameter("Semester",s);
	cout<<"Enter WeekDay: ";cin.getline(s,512);
	request.addParameter("Weekday",s);
	cout<<"Enter Max Attendants: ";cin.getline(s,512);
	request.addParameter("MaxAttendants",s);
	runRequest(intersil,request);
}
string AddAdmin(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Administrator ID: ";cin.getline(s,512);
	RequestData request(ADD_PERSON);
	request.addParameter("ID",s);
	cout<<"Enter First Name: ";cin.getline(s,512);
	request.addParameter("FirstName",s);
	cout<<"Enter Last Name: ";cin.getline(s,512);
	request.addParameter("LastName",s);
	request.addParameter("Semester","1");
	cout<<"Enter Address: ";cin.getline(s,512);
	request.addParameter("Address",s);
	cout<<"Enter Birth Day: ";cin.getline(s,512);
	request.addParameter("BirthDay",s);
	cout<<"Enter Birth Month: ";cin.getline(s,512);
	request.addParameter("BirthMonth",s);
	cout<<"Enter Birth Year: ";cin.getline(s,512);
	request.addParameter("BirthYear",s);
	request.addParameter("Type",USER_TYPE_TO_STRING(TYPE_ADMINISTRATOR));
	request.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(ADMINISTRATOR));
	runRequest(intersil,request);
	return request.getParameter("ID");
}
void AddLecturer(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Lecturer ID: ";cin.getline(s,512);
	RequestData request(ADD_PERSON);
	request.addParameter("ID",s);
	cout<<"Enter First Name: ";cin.getline(s,512);
	request.addParameter("FirstName",s);
	cout<<"Enter Last Name: ";cin.getline(s,512);
	request.addParameter("LastName",s);
	request.addParameter("Semester","1");
	cout<<"Enter Address: ";cin.getline(s,512);
	request.addParameter("Address",s);
	cout<<"Enter Birth Day: ";cin.getline(s,512);
	request.addParameter("BirthDay",s);
	cout<<"Enter Birth Month: ";cin.getline(s,512);
	request.addParameter("BirthMonth",s);
	cout<<"Enter Birth Year: ";cin.getline(s,512);
	request.addParameter("BirthYear",s);
	request.addParameter("Type",USER_TYPE_TO_STRING(TYPE_LECTURER));
	request.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(LECTURER));
	runRequest(intersil,request);
}
void AddStudent(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Student ID: ";cin.getline(s,512);
	RequestData request(ADD_PERSON);
	request.addParameter("ID",s);
	cout<<"Enter First Name: ";cin.getline(s,512);
	request.addParameter("FirstName",s);
	cout<<"Enter Last Name: ";cin.getline(s,512);
	request.addParameter("LastName",s);
	cout<<"Enter Semester: ";cin.getline(s,512);
	request.addParameter("Semester",s);
	cout<<"Enter Address: ";cin.getline(s,512);
	request.addParameter("Address",s);
	cout<<"Enter Birth Day: ";cin.getline(s,512);
	request.addParameter("BirthDay",s);
	cout<<"Enter Birth Month: ";cin.getline(s,512);
	request.addParameter("BirthMonth",s);
	cout<<"Enter Birth Year: ";cin.getline(s,512);
	request.addParameter("BirthYear",s);
	request.addParameter("Type",USER_TYPE_TO_STRING(TYPE_STUDENT));
	request.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(STUDENT));
	runRequest(intersil,request);
}
void DelLecturer(Intersil &intersil)
{
	cout<<"Not Implemented Yet - Big Problem\n";
}
void DelStudent(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Student ID: ";cin.getline(s,512);
	RequestData request(DELETE_PERSON);
	request.addParameter("ID",s);
	runRequest(intersil,request);

}
void AddCourse(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Course ID: ";cin.getline(s,512);
	RequestData request(ADD_COURSE);
	request.addParameter("ID",s);
	cout<<"Enter Course Name: ";cin.getline(s,512);
	request.addParameter("CourseName",s);
	cout<<"Enter Semester: ";cin.getline(s,512);
	request.addParameter("Semester",s);
	cout<<"Enter Lecture #1 Start Hour: ";cin.getline(s,512);
	request.addParameter("Start_Hour",s);
	cout<<"Enter Lecture #1 End Hour: ";cin.getline(s,512);
	request.addParameter("End_Hour",s);
	cout<<"Enter Lecture #1 Week Day: ";cin.getline(s,512);
	request.addParameter("Weekday",s);
	cout<<"Enter Lecture #1 Lecturer ID: ";cin.getline(s,512);
	request.addParameter("LectID",s);
	cout<<"Enter Lecture #1 Max Attendants: ";cin.getline(s,512);
	request.addParameter("MaxAttendants",s);
	cout<<"Enter Lecture #2 Start Hour: ";cin.getline(s,512);
	request.addParameter("Start_Hour2",s);
	cout<<"Enter Lecture #2 End Hour: ";cin.getline(s,512);
	request.addParameter("End_Hour2",s);
	cout<<"Enter Lecture #2 Week Day: ";cin.getline(s,512);
	request.addParameter("Weekday2",s);
	cout<<"Enter Lecture #2 Lecturer ID: ";cin.getline(s,512);
	request.addParameter("LectID2",s);
	cout<<"Enter Lecture #2 Max Attendants: ";cin.getline(s,512);
	request.addParameter("MaxAttendants2",s);
	runRequest(intersil,request);
}
void DelCourse(Intersil &intersil)
{
	char s[512];
	cout<<"Enter Course ID: ";cin.getline(s,512);
	RequestData request(DELETE_COURSE);
	request.addParameter("ID",s);
	runRequest(intersil,request);
	
}
void AddPreRequisite(Intersil &intersil)
{
	RequestData request(ADD_COURSE_PREREQUISITE);
	char s[512];
	cout<<"Enter Course ID: ";cin.getline(s,512);
 	request.addParameter("CourseID",s);
	cout<<"Enter Pre Requisite Course ID: ";cin.getline(s,512);
	request.addParameter("PreRequisitCourseID",s);
	runRequest(intersil,request);
}
void EditPerson(Intersil &intersil,int type,int permission)
{
	char s[512];
	RequestData request(EDIT_PERSON);
	cout<<"Enter Person ID: ";cin.getline(s,512);
	request.addParameter("ID",s);
	cout<<"Enter First Name: ";cin.getline(s,512);
	request.addParameter("FirstName",s);
	cout<<"Enter Last Name: ";cin.getline(s,512);
	request.addParameter("LastName",s);
	cout<<"Enter Semester: ";cin.getline(s,512);
	request.addParameter("Semester",s);
	cout<<"Enter Address: ";cin.getline(s,512);
	request.addParameter("Address",s);
	cout<<"Enter Birth Day: ";cin.getline(s,512);
	request.addParameter("BirthDay",s);
	cout<<"Enter Birth Month: ";cin.getline(s,512);
	request.addParameter("BirthMonth",s);
	cout<<"Enter Birth Year: ";cin.getline(s,512);
	request.addParameter("BirthYear",s);
	request.addParameter("Type",USER_TYPE_TO_STRING(type));
	request.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(permission));
	runRequest(intersil,request);
}
void RegisterStudentToCourse(Intersil &intersil)
{
	char s[512];
	RequestData request(REGISTER_STUDENT_COURSE);
	cout<<"Enter Student ID: ";cin.getline(s,512);
	request.addParameter("StudentID",s);
	cout<<"Enter Course ID: ";cin.getline(s,512);
	request.addParameter("CourseID",s);
	cout<<"Enter Lecturer ID: ";cin.getline(s,512);
	request.addParameter("LectID",s);
	cout<<"Enter Start Hour : ";cin.getline(s,512);
	request.addParameter("Start_Hour",s);
	cout<<"Enter End Hour : ";cin.getline(s,512);
	request.addParameter("End_Hour",s);
	cout<<"Enter Semester: ";cin.getline(s,512);
	request.addParameter("Semester",s);
	cout<<"Enter Weekday: ";cin.getline(s,512);
	request.addParameter("Weekday",s);
	cout<<"Student has completed the course?(0=NO,1=YES): ";cin.getline(s,512);
	request.addParameter("Completed",s);
	runRequest(intersil,request);
}

void Logout(Intersil &intersil)
{
	RequestData request(LOGOUT);
 	request.addParameter("ID",intersil.getLoggedUserId());
 	runRequest(intersil,request);
}

void rptListAllCourses(Intersil &intersil)
{
	RequestData request(GET_ALL_COURSE);
	runRequest(intersil,request);
}

void rptListAllCoursesForSemester(Intersil &intersil)
{
	char s[512];
	RequestData request(GET_COURSES_FOR_SEMESTER);
	cout<<"Enter Semester: ";cin.getline(s,512);
 	request.addParameter("Semester",s);
	runRequest(intersil,request);
}
void rptStudentReport(Intersil & intersil)
{
	char s[512];
	RequestData request(GET_PERSON_DATA);
	cout<<"Enter Student ID: ";cin.getline(s,512);
 	request.addParameter("ID",s);
	runRequest(intersil,request);
}
void rptCourseReport(Intersil &intersil)
{
	char s[512];
	RequestData request(GET_COURSE_DATA);
	cout<<"Enter Course ID: ";cin.getline(s,512);
 	request.addParameter("ID",s);
	runRequest(intersil,request);
}


void reportsMenu(Intersil &intersil)
{
	char ch;
	do
	{
		cout<<"\nReports Menu\n";
		cout<<"(L)list of all courses\n";
		cout<<"(M)list of all courses on semester\n";
		cout<<"(S)Student report\n";
		cout<<"(C)Course report\n";
		cout<<"(Q)return\n";
		cin>>ch;
		cin.ignore(1,'\n');
		switch(ch)
		{
		case 'l':
			//run list all courses
			rptListAllCourses(intersil);
			break;
		case 'm':
			//run list all courses by semester
			rptListAllCoursesForSemester(intersil);
			break;
		case 's':
			//run student report
			rptStudentReport(intersil);
			break;
		case 'c':
			//run course report
			rptCourseReport(intersil);
			break;
		}
	}while (ch!='q');

}


void loggedInMenu(Intersil &intersil)
{
	char ch;
	do
	{
		cout<<"\nUser Logged In: "<<intersil.getLoggedUserName()<<"\n";
		if(intersil.getUserPermissionLevel()==ADMINISTRATOR)
		{
			cout<<"(V)add Administrator\n";
			cout<<"(L)add Lecturer\n";
			cout<<"(X)remove Lecturer\n";
			cout<<"(C)add Course\n";
			cout<<"(R)remove Course\n";
			cout<<"(P)add a prerequisite to a course\n";
			cout<<"(Z)edit Lecturer data\n";
			cout<<"(M)edit Administrator data\n";
			cout<<"(A)assign a lecturer to a course\n";
			cout<<"(S)add Student\n";
			cout<<"(D)remove Student\n";
		}
		cout<<"(G)register Student to course\n";
		cout<<"(E)edit Student data\n";
		cout<<"(U)reports menu\n";
		cout<<"(O)logout\n";
		cout<<"(Q)return\n";
		
		cin>>ch;
		cin.ignore(1,'\n');
		switch(ch)
		{
		case 'o':
			//add a admin
			Logout(intersil);
			return;
			break;
		case 'm':
			//add a admin
			EditPerson(intersil,TYPE_ADMINISTRATOR,ADMINISTRATOR);
			break;
		case 'v':
			//add a admin
			AddAdmin(intersil);
			break;
		case 'a':
			//run assign lecturer to course
			AssignLecturerToAcourse(intersil);
			break;
		case 'l':
			//run add lecturer
			AddLecturer(intersil);
			break;
		case 'x':
			//run del lecturer
			DelLecturer(intersil);
			break;
		case 'c':
			//run add course
			AddCourse(intersil);
			break;
		case 'r':
			//run del course
			DelCourse(intersil);
			break;
		case 'p':
			//run add a prerequisite
			AddPreRequisite(intersil);
			break;
		case 'z':
			//run edit lecturer
			EditPerson(intersil,TYPE_LECTURER,LECTURER);
			break;
		case 's':
			//run add student
			AddStudent(intersil);
			break;
		case 'd':
			//run del student
			DelStudent(intersil);
			break;
		case 'g':
			//run register student course
			RegisterStudentToCourse(intersil);
			break;
		case 'e':
			//run edit student data
			EditPerson(intersil,TYPE_STUDENT,STUDENT);
			break;
		case 'u':
			//run reports menu
			reportsMenu(intersil);
			break;
		}
	}while (ch!='q');
}


int runRequest(Intersil &intersil,Request &request)
{
	auto_ptr<Reply> reply;
	try{
	reply=intersil.userRequest(request);
	}catch(...){
		cout<<"System Failed while proccessing request: "<<MESSAGE_TYPE_TO_STRING(request.getRequestType())<<endl;
		return 1;
	}
	switch(reply->getReplyType())
	{
	case LOGIN_SUCCESS:
		cout<<"Logged in: "<<intersil.getLoggedUserName()<<" AS "<<USER_PERMISSION_LEVEL_TO_STRING(intersil.getUserPermissionLevel())<<endl;
		break;
	case LOGIN_FAILED:
		cout<<"Failed to log in "<<request.getParameter("ID")<<endl;
		break;
	case DB_REQUEST_SUCCESS:
		cout<<"Operation Completed : "<<MESSAGE_TYPE_TO_STRING(request.getRequestType()) <<endl;
		switch(request.getRequestType())
		{
		case GET_PERSON_DATA:
			cout<<"Person Report:\n";
			reply->print_recordset();
			break;
		case GET_COURSE_DATA:
			cout<<"Course Report:\n";
			reply->print_recordset();
			break;
			cout<<"Course Report by Semester:\n";
		case GET_COURSES_FOR_SEMESTER:
			reply->print_recordset();
			break;
			cout<<"All Courses Report:\n";
		case GET_ALL_COURSE:
			reply->print_recordset();
			break;
		}
		break;
	case DB_REQUEST_FAIL:
		cout<<"Operation Failed: "<<MESSAGE_TYPE_TO_STRING(request.getRequestType())<<endl;
		cout<<"Error: "<<reply->getErrDescription()<<endl;
		break;
	case INVALID_INPUT:
		cout<<"Operation Failed: "<<MESSAGE_TYPE_TO_STRING(request.getRequestType()) <<" Invalid Input Entered\n";
		break;
	case NO_PERMISSION:
		cout<<"Operation Failed: "<<MESSAGE_TYPE_TO_STRING(request.getRequestType()) <<" User does not have permission to run this request\n";
		break;
	case LOGOUT_SUCCESS:
		cout<<"Logged out succesfuly"<<endl;
		break;
	case LOGOUT_FAILED:
		cout<<"Logged out with errors"<<endl;
	default:
		cout<<"Unknown Reply From system\n";
		break;
	}
	return 1;
}




void mainMenu(Intersil &intersil)
{
	char ch;
	do
	{
		cout<<"\nMain Menu\n(L)ogin\n";
		cout<<"(S)add a new student\n";
		cout<<"(Q)quit\n";
		cin>>ch;
		cin.ignore(1,'\n');
		switch(ch)
		{
		case 'l':
			//run login
			if (Login(intersil))loggedInMenu(intersil);
			break;
		case 's':
			//run add student
			AddStudent(intersil);
			break;
		}
	}while (ch!='q');
}

int main()
{
	cout<<"Intersil Demonstration Program"<<endl;
	
 	Intersil intersil;
	intersil.addSystemAccount();
	cout<<"this is the first time you have run intersil\nYou must now enter a administrator account\n";
	RequestData request(LOGIN);
 	request.addParameter("ID","Intersil");
 	intersil.userRequest(request);
	if(!intersil.isLoggedIn())
	{
		cout<<"System Error: could not connect to Intersil..Aborting\n";
		return 0;
	}	
	string s=AddAdmin(intersil);
	RequestData request2(LOGOUT);
	request.addParameter("ID","Intersil");
	intersil.userRequest(request2);
	intersil.delSystemAccount();
	char ch;
	cout<<"Enter Demonstartion data? (Y/N) : ";cin>>ch;
	if (ch=='y')addDemoData(intersil,s);
 	mainMenu(intersil);
	return 0;
}

void addDemoData(Intersil &intersil,string myid)
{
	cout<<"Adding Demo Data...\n";
 	RequestData request(LOGIN);
 	request.addParameter("ID",myid);
 	runRequest(intersil,request);
	RequestData req_Add(ADD_PERSON);
	req_Add.addParameter("ID","2");
	req_Add.addParameter("FirstName","jorden");
	req_Add.addParameter("LastName","shechter");
	req_Add.addParameter("Semester","1");
	req_Add.addParameter("Type",USER_TYPE_TO_STRING(TYPE_STUDENT));
	req_Add.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(STUDENT));
	req_Add.addParameter("Address","Demo Land");
	req_Add.addParameter("BirthDay","1");
	req_Add.addParameter("BirthMonth","1");
	req_Add.addParameter("BirthYear","1980");
	runRequest(intersil,req_Add);
	RequestData req_Add001(ADD_PERSON);
	req_Add001.addParameter("ID","1001");
	req_Add001.addParameter("FirstName","dotan");
	req_Add001.addParameter("LastName","roitman");
	req_Add001.addParameter("Semester","2");
	req_Add001.addParameter("Type",USER_TYPE_TO_STRING(TYPE_STUDENT));
	req_Add001.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(STUDENT));
	req_Add001.addParameter("Address","Demo Land");
	req_Add001.addParameter("BirthDay","2");
	req_Add001.addParameter("BirthMonth","2");
	req_Add001.addParameter("BirthYear","1981");
	runRequest(intersil,req_Add001);
	RequestData req_Add002(ADD_PERSON);
	req_Add002.addParameter("ID","1002");
	req_Add002.addParameter("FirstName","asaf");
	req_Add002.addParameter("LastName","paz");
	req_Add002.addParameter("Semester","1");
	req_Add002.addParameter("Type",USER_TYPE_TO_STRING(TYPE_STUDENT));
	req_Add002.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(STUDENT));
	req_Add002.addParameter("Address","Demo Land");
	req_Add002.addParameter("BirthDay","3");
	req_Add002.addParameter("BirthMonth","3");
	req_Add002.addParameter("BirthYear","1983");
	runRequest(intersil,req_Add002);
	RequestData req_Add003(ADD_PERSON);
	req_Add003.addParameter("ID","1003");
	req_Add003.addParameter("FirstName","some");
	req_Add003.addParameter("LastName","other guy");
	req_Add003.addParameter("Semester","1");
	req_Add003.addParameter("Type",USER_TYPE_TO_STRING(TYPE_STUDENT));
	req_Add003.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(STUDENT));
	req_Add003.addParameter("Address","Demo Land");
	req_Add003.addParameter("BirthDay","4");
	req_Add003.addParameter("BirthMonth","4");
	req_Add003.addParameter("BirthYear","1984");
	runRequest(intersil,req_Add003);
	RequestData req_Add2(ADD_PERSON);
	req_Add2.addParameter("ID","1004");
	req_Add2.addParameter("FirstName","mush");
	req_Add2.addParameter("LastName","hashor");
	req_Add2.addParameter("Semester","1");
	req_Add2.addParameter("Type",USER_TYPE_TO_STRING(TYPE_LECTURER));
	req_Add2.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(LECTURER));
	req_Add2.addParameter("Address","Demo Land");
	req_Add2.addParameter("BirthDay","5");
	req_Add2.addParameter("BirthMonth","5");
	req_Add2.addParameter("BirthYear","1985");
	runRequest(intersil,req_Add2);
	RequestData req_Add666(ADD_PERSON);
	req_Add666.addParameter("ID","1005");
	req_Add666.addParameter("FirstName","bugs");
	req_Add666.addParameter("LastName","bunny");
	req_Add666.addParameter("Semester","1");
	req_Add666.addParameter("Type",USER_TYPE_TO_STRING(TYPE_LECTURER));
	req_Add666.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(LECTURER));
	req_Add666.addParameter("Address","Demo Land");
	req_Add666.addParameter("BirthDay","6");
	req_Add666.addParameter("BirthMonth","6");
	req_Add666.addParameter("BirthYear","1986");
	runRequest(intersil,req_Add666);
	RequestData req_Add667(ADD_PERSON);
	req_Add667.addParameter("ID","1006");
	req_Add667.addParameter("FirstName","bar");
	req_Add667.addParameter("LastName","refaely");
	req_Add667.addParameter("Semester","1");
	req_Add667.addParameter("Type",USER_TYPE_TO_STRING(TYPE_LECTURER));
	req_Add667.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(LECTURER));
	req_Add667.addParameter("Address","Demo Land");
	req_Add667.addParameter("BirthDay","7");
	req_Add667.addParameter("BirthMonth","7");
	req_Add667.addParameter("BirthYear","1987");
	runRequest(intersil,req_Add667);
	RequestData req_Add3(ADD_COURSE);
	req_Add3.addParameter("ID","11011");
	req_Add3.addParameter("CourseName","Hedva I");
	req_Add3.addParameter("Semester","1");
	req_Add3.addParameter("Start_Hour","1");
	req_Add3.addParameter("End_Hour","4");
	req_Add3.addParameter("Weekday","1");
	req_Add3.addParameter("Start_Hour2","5");
	req_Add3.addParameter("End_Hour2","8");
	req_Add3.addParameter("Weekday2","1");
	req_Add3.addParameter("LectID","1005");
	req_Add3.addParameter("LectID2","1006");
	req_Add3.addParameter("MaxAttendants","2");
	req_Add3.addParameter("MaxAttendants2","2");
	runRequest(intersil,req_Add3);
	RequestData req_Add31(ADD_COURSE);
	req_Add31.addParameter("ID","12014");
	req_Add31.addParameter("CourseName","Algorithms II");
	req_Add31.addParameter("Semester","2");
	req_Add31.addParameter("Start_Hour","1");
	req_Add31.addParameter("End_Hour","5");
	req_Add31.addParameter("Weekday","1");
	req_Add31.addParameter("Start_Hour2","1");
	req_Add31.addParameter("End_Hour2","5");
	req_Add31.addParameter("Weekday2","1");
	req_Add31.addParameter("LectID","1005");
	req_Add31.addParameter("LectID2","1004");
	req_Add31.addParameter("MaxAttendants","2");
	req_Add31.addParameter("MaxAttendants2","2");
	runRequest(intersil,req_Add31);
	RequestData req_Add30(ADD_COURSE);
	req_Add30.addParameter("ID","12013");
	req_Add30.addParameter("CourseName","Algorithms I");
	req_Add30.addParameter("Semester","1");
	req_Add30.addParameter("Start_Hour","1");
	req_Add30.addParameter("End_Hour","5");
	req_Add30.addParameter("Weekday","1");
	req_Add30.addParameter("Start_Hour2","1");
	req_Add30.addParameter("End_Hour2","5");
	req_Add30.addParameter("Weekday2","1");
	req_Add30.addParameter("LectID","1006");
	req_Add30.addParameter("LectID2","1004");
	req_Add30.addParameter("MaxAttendants","2");
	req_Add30.addParameter("MaxAttendants2","2");
	runRequest(intersil,req_Add30);
	RequestData req_Add4(ADD_COURSE);
	req_Add4.addParameter("ID","11012");
	req_Add4.addParameter("CourseName","Hedva II");
	req_Add4.addParameter("Semester","2");
	req_Add4.addParameter("Start_Hour","1");
	req_Add4.addParameter("End_Hour","5");
	req_Add4.addParameter("Weekday","2");
	req_Add4.addParameter("Start_Hour2","6");
	req_Add4.addParameter("End_Hour2","8");
	req_Add4.addParameter("Weekday2","2");
	req_Add4.addParameter("LectID","1004");
	req_Add4.addParameter("LectID2","1004");
	req_Add4.addParameter("MaxAttendants","2");
	req_Add4.addParameter("MaxAttendants2","2");
	runRequest(intersil,req_Add4);
	RequestData req_Add404(ADD_COURSE);
	req_Add404.addParameter("ID","12345");
	req_Add404.addParameter("CourseName","Shimushit");
	req_Add404.addParameter("Semester","3");
	req_Add404.addParameter("Start_Hour","1");
	req_Add404.addParameter("End_Hour","5");
	req_Add404.addParameter("Weekday","2");
	req_Add404.addParameter("Start_Hour2","6");
	req_Add404.addParameter("End_Hour2","8");
	req_Add404.addParameter("Weekday2","2");
	req_Add404.addParameter("LectID","1005");
	req_Add404.addParameter("LectID2","1006");
	req_Add404.addParameter("MaxAttendants","2");
	req_Add404.addParameter("MaxAttendants2","2");
	runRequest(intersil,req_Add404);
	RequestData request24(ADD_COURSE_PREREQUISITE);
 	request24.addParameter("CourseID","12345");
	request24.addParameter("PreRequisitCourseID","11012");
	runRequest(intersil,request24);
	RequestData request25(ADD_COURSE_PREREQUISITE);
 	request25.addParameter("CourseID","12345");
	request25.addParameter("PreRequisitCourseID","12014");
	runRequest(intersil,request25);
	RequestData request26(ADD_COURSE_PREREQUISITE);
 	request26.addParameter("CourseID","12014");
	request26.addParameter("PreRequisitCourseID","12013");
	runRequest(intersil,request26);
	RequestData request23(ADD_COURSE_PREREQUISITE);
 	request23.addParameter("CourseID","11012");
	request23.addParameter("PreRequisitCourseID","11011");
	runRequest(intersil,request23);
	RequestData req_Add5(ASSIGN_COURSE_LECTURER);
	req_Add5.addParameter("LectID","1004");
	req_Add5.addParameter("CourseID","11011");
	req_Add5.addParameter("Start_Hour","1");
	req_Add5.addParameter("End_Hour","5");
	req_Add5.addParameter("Semester","1");
	req_Add5.addParameter("Weekday","2");
	req_Add5.addParameter("MaxAttendants","5");
	runRequest(intersil,req_Add5);
	RequestData req_Add6(ASSIGN_COURSE_LECTURER);
	req_Add6.addParameter("LectID","1005");
	req_Add6.addParameter("CourseID","11011");
	req_Add6.addParameter("Start_Hour","1");
	req_Add6.addParameter("End_Hour","5");
	req_Add6.addParameter("Semester","1");
	req_Add6.addParameter("Weekday","2");
	req_Add6.addParameter("MaxAttendants","2");
	runRequest(intersil,req_Add6);
	RequestData req_Add9(ASSIGN_COURSE_LECTURER);
	req_Add9.addParameter("LectID","1006");
	req_Add9.addParameter("CourseID","11012");
	req_Add9.addParameter("Start_Hour","1");
	req_Add9.addParameter("End_Hour","5");
	req_Add9.addParameter("Semester","2");
	req_Add9.addParameter("Weekday","1");
	req_Add9.addParameter("MaxAttendants","2");
	runRequest(intersil,req_Add9);
	RequestData req_Add70(REGISTER_STUDENT_COURSE);
	req_Add70.addParameter("StudentID","2");
	req_Add70.addParameter("CourseID","12013");
	req_Add70.addParameter("LectID","1006");
	req_Add70.addParameter("Start_Hour","1");
	req_Add70.addParameter("End_Hour","5");
	req_Add70.addParameter("Semester","1");
	req_Add70.addParameter("Weekday","1");
	req_Add70.addParameter("Completed","0");
	runRequest(intersil,req_Add70);
	RequestData req_Add7(REGISTER_STUDENT_COURSE);
	req_Add7.addParameter("StudentID","2");
	req_Add7.addParameter("CourseID","11011");
	req_Add7.addParameter("LectID","1004");
	req_Add7.addParameter("Start_Hour","1");
	req_Add7.addParameter("End_Hour","5");
	req_Add7.addParameter("Semester","1");
	req_Add7.addParameter("Weekday","2");
	req_Add7.addParameter("Completed","0");
	runRequest(intersil,req_Add7);
	RequestData req_Add004(REGISTER_STUDENT_COURSE);
	req_Add004.addParameter("StudentID","1002");
	req_Add004.addParameter("CourseID","11011");
	req_Add004.addParameter("LectID","1004");
	req_Add004.addParameter("Start_Hour","1");
	req_Add004.addParameter("End_Hour","5");
	req_Add004.addParameter("Semester","1");
	req_Add004.addParameter("Weekday","2");
	req_Add004.addParameter("Completed","0");
	runRequest(intersil,req_Add004);
	RequestData req_Add006(SET_STUDENT_COURSE_COMPLETED);
	req_Add006.addParameter("StudentID","1002");
	req_Add006.addParameter("CourseID","11011");
	req_Add006.addParameter("LectID","1006");
	req_Add006.addParameter("Start_Hour","1");
	req_Add006.addParameter("End_Hour","5");
	req_Add006.addParameter("Semester","1");
	req_Add006.addParameter("Weekday","2");
	req_Add006.addParameter("Completed","1");
	runRequest(intersil,req_Add006);
	RequestData req_Add005(REGISTER_STUDENT_COURSE);
	req_Add005.addParameter("StudentID","1003");
	req_Add005.addParameter("CourseID","11011");
	req_Add005.addParameter("LectID","1004");
	req_Add005.addParameter("Start_Hour","1");
	req_Add005.addParameter("End_Hour","5");
	req_Add005.addParameter("Semester","1");
	req_Add005.addParameter("Weekday","2");
	req_Add005.addParameter("Completed","0");
	runRequest(intersil,req_Add005);
	RequestData req_Add007(EDIT_PERSON);
	req_Add007.addParameter("ID","1002");
	req_Add007.addParameter("FirstName","my");
	req_Add007.addParameter("LastName","student3");
	req_Add007.addParameter("Semester","2");
	req_Add007.addParameter("Type",USER_TYPE_TO_STRING(TYPE_STUDENT));
	req_Add007.addParameter("Permission",USER_PERMISSION_LEVEL_TO_STRING(STUDENT));
	runRequest(intersil,req_Add007);
	RequestData req_Add008(REGISTER_STUDENT_COURSE);
	req_Add008.addParameter("StudentID","1002");
	req_Add008.addParameter("CourseID","11012");
	req_Add008.addParameter("LectID","1006");
	req_Add008.addParameter("Start_Hour","1");
	req_Add008.addParameter("End_Hour","5");
	req_Add008.addParameter("Semester","2");
	req_Add008.addParameter("Weekday","1");
	req_Add008.addParameter("Completed","1");
	runRequest(intersil,req_Add008);
	RequestData request00011(LOGOUT);
 	request00011.addParameter("ID",myid);
 	runRequest(intersil,request00011);
	
	return;

	
}

